
import 'package:amap_flutter_search/src/entity/poi.dart';

class GeocodingResult {
  List<PoiAddress>? geocodeAddressList;

  GeocodingResult({this.geocodeAddressList});

  GeocodingResult.fromJson(Map<String, dynamic> json) {
    if (json['geocodeAddressList'] != null) {
      geocodeAddressList = <PoiAddress>[];
      json['geocodeAddressList'].forEach((v) {
        geocodeAddressList!.add(PoiAddress.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (geocodeAddressList != null) {
      data['geocodeAddressList'] =
          geocodeAddressList!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class ReGeocodingResult {
  RegeocodeAddress? regeocodeAddress;

  ReGeocodingResult({this.regeocodeAddress});

  ReGeocodingResult.fromJson(Map<String, dynamic> json) {
    regeocodeAddress = json['regeocodeAddress'] != null
        ? RegeocodeAddress.fromJson(json['regeocodeAddress'])
        : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (regeocodeAddress != null) {
      data['regeocodeAddress'] = regeocodeAddress!.toJson();
    }
    return data;
  }
}

class RegeocodeAddress {
  dynamic roadinters;
  dynamic roads;
  PoiAddress? addressComponent;
  String? formattedAddress;
  dynamic pois;
  dynamic aois;

  RegeocodeAddress(
      {this.roadinters,
        this.roads,
        this.addressComponent,
        this.formattedAddress,
        this.pois,
        this.aois});

  RegeocodeAddress.fromJson(Map<String, dynamic> json) {
    roadinters = json['roadinters'];
    roads = json['roads'];
    addressComponent = json['addressComponent'] != null
        ? PoiAddress.fromJson(json['addressComponent'])
        : null;
    formattedAddress = json['formattedAddress'];
    pois = json['pois'];
    aois = json['aois'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['roadinters'] = roadinters;
    data['roads'] = this.roads;
    if (this.addressComponent != null) {
      data['addressComponent'] = this.addressComponent!.toJson();
    }
    data['formattedAddress'] = this.formattedAddress;
    data['pois'] = this.pois;
    data['aois'] = this.aois;
    return data;
  }
}
